
#include "capPicture.h"
#include <iostream>

int capPicture(const int inLUserID, const int channel, std::string inOutPicturePath)
{
    int iRet;
    NET_DVR_JPEGPARA strPicPara = {0};
    //strPicPara.wPicQuality = 2;
    //strPicPara.wPicSize = 0;
    strPicPara.wPicQuality = 0;	//图片质量系数：0-最好，1-较好，2-一般 
	strPicPara.wPicSize = 500;	//500-384*288
   
    iRet = NET_DVR_CaptureJPEGPicture(inLUserID, channel, &strPicPara, (char*)inOutPicturePath.c_str());
    if (!iRet)
    {
        printf("pyd1---NET_DVR_CaptureJPEGPicture error, %d\n", NET_DVR_GetLastError());
        return -1;       //-1
    }


    return 0;
}

/*
* get imgBuf
* inLUserID
    [in]
* channel
    [in]
* imgBuff
    [in] save imgData buff
* imgBuffLen
    [in] imgData buff size
* lpSizeReturned
    [out] return imgData size
*/
void capPicture_v3(const int inLUserID, const int channel, char *imgBuff, int imgBuffLen)
{
    int aaa = 0;
    return ;
    NET_DVR_JPEGPICTURE_WITH_APPENDDATA strPicPara;

    // int iRet = NET_DVR_CaptureJPEGPicture_WithAppendData(inLUserID, channel, &strPicPara );
    // int len = strPicPara.dwJpegPicHeight;
    // printf(".... %d\n", len);
    // if (!iRet)
    // {
    //     printf("pyd1---NET_DVR_CaptureJPEGPicture error, %d\n", NET_DVR_GetLastError());
    //     return -1;       //-1
    // }



    // return 0;


    // LPNET_DVR_JPEGPARA strPicPara2;
    // strPicPara2->wPicSize = 0;
    // strPicPara2->wPicSize = 500;

    // char imgBuff[1000000];
    // LPDWORD reLen;
    // iRet = NET_DVR_CaptureJPEGPicture_NEW(inLUserID, channel, strPicPara2 , imgBuff, sizeof(imgBuff), reLen);
    // int len = strPicPara2.dwJpegPicHeight;
    // printf(".... %d\n", len);
    // if (!iRet)
    // {
    //     printf("pyd1---NET_DVR_CaptureJPEGPicture error, %d\n", NET_DVR_GetLastError());
    //     return -1;       //-1
    // }


//     NET_DVR_JPEGPARA strPicPara = {0};
//     //strPicPara.wPicQuality = 2;
//     //strPicPara.wPicSize = 0;

//     strPicPara.wPicQuality = 0;  //图片质量系数：0-最好，1-较好，2-一般 
//     strPicPara.wPicSize = 500;   //0:352x288, 1:176x144, 2:704x576, 3:1600x1200, 4:800x600, ......   500:384x288

//     int iRet;

// return 0;
//     //unsigned int* 
//     LPDWORD lpSizeReturned;
//     iRet = NET_DVR_CaptureJPEGPicture_NEW(inLUserID, channel, &strPicPara, imgBuff, imgBuffLen, lpSizeReturned );
//     if (!iRet)
//     {
//         printf("pyd1---NET_DVR_CaptureJPEGPicture error, %d\n", NET_DVR_GetLastError());
//         return -1;       //-1
//     }
//     std::cout << lpSizeReturned << std::endl;
//     printf("......%d\n", sizeof(lpSizeReturned));

    // FILE *fp = NULL;
    // string imgpath = "/home/ljl/Pictures/" + getLocalTime_self() + ".jpg";
    // fp = fopen(const_cast<char*>(imgpath.c_str() ), "wb");
    // fwrite(imgBuff, imgLen, 1, fp);
    // fclose(fp);


}